<?php require APP_ROOT.'public/top.php';
$plan_id=pg('plan_id');
$plan_name=M('plan')->where(array('plan_id'=>$plan_id))->getfield('plan_name');
$type_id=pg('type_id');
?>

<div class="admincp-container unfold">
  <?php require APP_ROOT.'public/left.php';?>
  <div class="g-ct">
    <div class="account-cert-dialog" style=""><i class="v-dialog-close-btn v-icon v-icon-cross"></i>
      <div class="v-dialog-header">添加主体资质</div>
      <div class="v-dialog-body">
        <div class="formBox">
    <form action="index.php?m=cms&a=add_save" class="c-form c-form-dialog f-pzr" method="post" enctype="multipart/form-data" id="handleposition" onsubmit="return return_message()">
      <input name="data[date]" type="hidden" id="date" value="<?php echo time();?>" />
      <input name="data[version_id]" type="hidden" id="version_id" value="1" />
      <input name="data[type_id]" type="hidden" id="type_id" value="<?php echo $type_id;?>" />
      <input name="data[member_id]" type="hidden" id="member_id" value="<?php echo $member['member_id'];?>" />
      <input name="data[state]" type="hidden" id="state" value="1" />

            <div id="cert-main">
                    <?php
$list = M('input')->where(array('type_id'=>$type_id,'show_switch'=>2,'input_pid'=>array('exp','is null')))->order('date asc')->select();
foreach($list as $k=>$v){
?>
              <dl class="f-cb">
                <dt><?php echo $v['input_name']?>:</dt>
                <dd>
                  <?php
	switch($v['input_type_id']){
		case 1:
		?>
            <input name="data[<?php echo $v['field_name'];?>]" type="text" id="<?php echo $v['field_name'];?>" class="c-input required" />
            <?php
		break;
		case 2:
		?>
            <textarea name="data[<?php echo $v['field_name'];?>]" cols="60" rows="<?php echo $v['edit_size'];?>" id="<?php echo $v['field_name'];?>"></textarea>
            <?php
		break;
		case 3:
			echo fckeditor('data['.$v['field_name'].']',$v['edit_size'],'');
		break;
		case 4:
		?>
            <?php
		$input_p = M('input')->where(array('input_pid'=>$v['input_id']))->select();
		foreach($input_p as $k2=>$v2){
		?>
            <label>
              <input type="checkbox" name="data[<?php echo $v['field_name'];?>][]" value="<?php echo $v2['input_value']?>" />
              <?php echo $v2['input_name'];?> </label>
            &nbsp;&nbsp;
            <?php } ?>
            <?php
		break;
		case 5:
		?>
            <?php
		$input_p = M('input')->where(array('input_pid'=>$v['input_id']))->select();
		foreach($input_p as $k2=>$v2){
		?>
            <label>
              <input type="radio" name="data[<?php echo $v['field_name'];?>]" value="<?php echo $v2['input_value']?>" />
              <?php echo $v2['input_name'];?> </label>
            &nbsp;&nbsp;
            <?php } ?>
            <?php
		break;
		case 6:
		?>
            <select name="data[<?php echo $v['field_name'];?>]" id="<?php echo $v['field_name'];?>">
              <option value="0">请选择</option>
              <?php
		$input_p = M('input')->where(array('input_pid'=>$v['input_id']))->select();
		foreach($input_p as $k2=>$v2){
		?>
              <option value="<?php echo $v2['input_value'];?>"><?php echo $v2['input_name'];?></option>
              <?php } ?>
            </select>
            <?php
		break;
		case 7:
		?>
            <input name="<?php echo $v['field_name'];?>" id="<?php echo $v['field_name'];?>" type="file" />
            <?php
		break;
		case 8:
		?>
            <input name="data[<?php echo $v['field_name'];?>]" class="laydate-input c-input required" type="text" id="<?php echo $v['field_name'];?>" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" size="<?php echo $v['edit_size'];?>" />
            <?php
		break;
		case 9:
			$field_name=$v['field_name'];
		?>
            <div class="fieldset flash" id="fsUploadProgress" align="left"></div>
            <div id="divStatus">0 个文件已上传</div>
            <div> <span id="spanButtonPlaceHolder"></span><br />
              <input id="btnCancel" type="button" value="断开上传" onClick="swfu.cancelQueue();" style="margin-left: 2px; font-size: 8pt; height: 29px;" />
            </div>
            <input name="data[<?php echo $v['field_name'];?>]" type="hidden" id="<?php echo $v['field_name'];?>" size="<?php echo $v['edit_size'];?>" />
            <?php
		break;
	}
	?>
                </dd>
              </dl>
           <?php }?>
              
              
              
              <dl class="f-cb">
                <dt>导入文件:</dt>
                <dd>
                  <p class="f-gray"> 资质文件支持jpg、png、gif格式，单个文件最大2M </p>
                  <div class="uploader-container">
                  <div id="upload_btn_container_72x72" class="js-upload-btn-container">
                  <img src="" height="200" alt="" class="fileContainer" style="position:absolute; z-index:999;">
                  <input type="file" capture="camera" name="qualifications_img" id="qualifications_img" class="webuploader-element-invisible fileContainer" multiple="multiple" accept="image/jpeg,image/png" image="" onchange="previewFile()" style="position:relative !important; display:block;opacity: 0; z-index:10000 ">
                  
                   </div>
                  
                  
                    
                    <div class="file-editor" style="display: none;"><img src="" width="120" height="120"> <a href="#" class="file-editor-btn"></a></div>
                    <input name="cert" type="hidden" class="upload">
                  </div>
                </dd>
              </dl>
            </div>
            <dl class="f-cb">
              <dt>&nbsp;</dt>
              <dd><a id="submit" href="javascript:adsubmit()" class="c-btn1">保存提交</a></dd>
            </dl>
            <div id="dateCont" class="dateCont"></div>
          </form>
        </div>
      </div>
      <!---->
      <div class="v-dialog-mask" style="display: none;"></div>
    </div>
    
  </div>
</div>
<script>
function adsubmit(){
	$('#handleposition').submit();
}

function previewFile() {
  var preview = document.querySelector('img');
  var file    = document.querySelector('input[type=file]').files[0];
  var reader  = new FileReader();

  reader.onloadend = function () {
    preview.src = reader.result;
  }

  if (file) {
    reader.readAsDataURL(file);
  } else {
    preview.src = "";
  }
}


</script>
<?php require APP_ROOT.'public/bottom.php';?>
